package com.atguigu.yygh.order.listen;

import com.atguigu.yygh.model.order.OrderInfo;
import com.atguigu.yygh.order.service.OrderInfoService;
import com.atguigu.yygh.rabbitmq.constant.RabbitMQConstant;
import com.atguigu.yygh.rabbitmq.service.RabbitMQService;
import com.atguigu.yygh.vo.msm.MsmVo;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Author:hx
 * @DateTime:2022/11/21 16:21
 * @Description:
 */
@Component
public class OrderListen {

    @Autowired
    private OrderInfoService orderInfoService;
    @Autowired
    private RabbitMQService rabbitMQService;

    @RabbitListener(queues = RabbitMQConstant.QUEUE_TASK)
    public void remindPatient(){
        List<OrderInfo> orderInfoList = orderInfoService.getRemindPatient();
        for (OrderInfo orderInfo : orderInfoList) {
            MsmVo msmVo = new MsmVo();
            msmVo.setPhone(orderInfo.getPatientPhone());
            rabbitMQService.sendMessage(RabbitMQConstant.EXCHANGE_DIRECT_SMS,RabbitMQConstant.ROUTING_SMS,msmVo);
        }
    }
}
